package MonthGame.HardCrazyProblem;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int [] num = new int [n];
        for(int i=0;i<n;i++) num[i] = s.nextInt();
        Arrays.sort(num);
        int ans = 0;
        for(int i=1;i<n;i+=2) ans+=num[i]-num[i-1];
        System.out.print(ans);
    }
}
